<template>
	<view class="header">
		<text class="title">查询流程模板</text>
	</view>
	<view class="template-container">
		<view class="template-card" v-for="(item, index) in templateList" :key="index" @click="viewDetail(item)">
			<view class="card-header">
				<text class="template-title">{{ item.typeName }}</text>
			</view>
			<view class="card-body">
				<text class="template-desc">{{ item.description }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				templateList: []
			};
		},
		mounted() {
			this.getTemplates()
		},
		methods: {
			getTemplates() {
				this.token = uni.getStorageSync('token');
				uni.request({

					url: 'http://localhost:8082/admin/processes',
					method: 'GET',
					header: {
						'Authorization': 'Bearer ' + this.token, // 使用 Token
						'Content-Type': 'application/json'
					},
					success: res => {
						if (res.data.code === 200) {
							this.templateList = res.data.data
						}
					}
				});
			},
			viewDetail(item) {
				uni.navigateTo({
					url: `/pages/admin/templateDetail/templateDetail?typeId=${item.typeId}`
				})
			}
		}
	};
</script>

<style scoped>
	.template-container {
		padding: 16px;
	}

	.template-card {
		background-color: #e6f7ff;
		border-left: 4px solid #1890ff;
		padding: 16px;
		border-radius: 12px;
		margin-bottom: 12px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	}

	.template-title {
		font-size: 18px;
		font-weight: bold;
		color: #1890ff;
	}

	.template-desc {
		font-size: 14px;
		color: #555;
		margin-top: 8px;
	}

	.header {
		background: linear-gradient(to right, #3b82f6, #2563eb);
		color: white;
		padding: 20rpx;
		text-align: center;
		border-radius: 12rpx;
		margin-bottom: 24rpx;
	}

	.title {
		font-size: 36rpx;
		font-weight: bold;
	}
</style>